Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mobile): add integration with gateway backend for notifications feature #4878

Open
wants to merge 25 commits into
base: dev
Choose a base branch
from

Conversation

Jonathansoufer
Copy link
Contributor

What it solves

Resolves #

How this PR fixes it

How to test it

Screenshots

Checklist

  • I've tested the branch on mobile 📱
  • I've documented how it affects the analytics (if at all) 📊
  • I've written a unit/e2e test for it (if applicable) 🧑‍💻

@Jonathansoufer Jonathansoufer self-assigned this Feb 4, 2025
@Jonathansoufer Jonathansoufer marked this pull request as ready for review February 18, 2025 16:50
Copy link
Contributor

@compojoom compojoom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks very good 👍 ! I sadly could not test it yet as some of your dependencies are not 100% correct in the PR. (I guess due to a rebase or something)

Comment on lines +15 to +19
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
'Set-Cookie': 'HttpOnly;Secure;SameSite=None',
},
Copy link
Contributor

@compojoom compojoom Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this block necessary? Especially the set-cookie header is a response header. It shouldn't do anything here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, without this all requests fails due unauthorized.

dispatch(toggleAppNotifications(!isAppNotificationEnabled))
if (!isAppNotificationEnabled) {
await deleteDelegate()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if for whatever reason this fails? Is the user still going to receive push notifications?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the order of the calls to avoid disable redux without the confirmation of BE.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jonathansoufer I have my doubts that this if(!error) check is goin to work reliably. the useDelegateKey hook returns an error. here you await the deleteDelegate and thje deleteDelegate function might set the error, but if does the notificationContainer needs to rerender. I'm not sure how the flow of the code is going to be. Isn't delegate always be null, since you are in the callback and at the moment the callback has started it is null 🤷

Wouldn't it be easier of the deleteDelegate and createDelegate return the error or throw?

reducers: {
addDelegatedAddress: (state, action: PayloadAction<{ delegatedAddress: Address; safes: SafeInfo[] }>) => {
const { delegatedAddress, safes } = action.payload
state.delegatedSafes[delegatedAddress] = { safes }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't run the branch to inspect the final form of the state, but as far as I understand we end up with
delegated.delegatedSafes
Can't we just have a slice delegates and then have a mapping of delegatedAddress to safes? Why do we need the extra nesting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Changed.

updateDelegatedAddress: (state, action: PayloadAction<{ delegatedAddress: Address; safes: SafeInfo[] }>) => {
const { delegatedAddress, safes } = action.payload

state.delegatedSafes[delegatedAddress] = { ...safes, safes }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should feel lucky that Immer is part of redux-toolkit 😄
https://redux-toolkit.js.org/usage/immer-reducers

@compojoom
Copy link
Contributor

@Jonathansoufer - I built the app locally and installed on my phone, but when I click on "turn on" notificatoins and navigate to the settings I don't have any notifications to choose from? The permission is not in the list?

@@ -1,7 +1,9 @@
//@ts-ignore
globalThis.RNFB_SILENCE_MODULAR_DEPRECATION_WARNINGS = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we better move this to the entry point of the application. It's a bit weird to have this global var first in the FCMService. It seems to be a global thing that react-native-firebase "needs".

Comment on lines +57 to +75
if (delegatedAccountType === DELEGATED_ACCOUNT_TYPE.REGULAR) {
await authVerifyV1({
siweDto: {
message,
signature,
},
})
} else {
delegatesPostDelegateV2({
chainId,
createDelegateDto: {
safe: safeAddress,
delegator: signer.address,
delegate: delegatedAccount.address,
signature,
label: DELEGATED_ACCOUNT_TYPE.OWNER,
},
})
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully understand this block. Why does a regular user need to authenticate, but an owner doesn't?

if (Platform.OS === 'ios') {
Linking.openSettings()
} else {
notifee.openNotificationSettings()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it necessary that we use the notifee openNotificationSettings? isn't Linking.openSettings() also working on android?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants